<include file="Public/min-header" />
<link href="__PUBLIC__/plugins/daterangepicker/daterangepicker-bs3.css" rel="stylesheet" type="text/css" />
<script src="__PUBLIC__/plugins/daterangepicker/moment.min.js" type="text/javascript"></script>
<script src="__PUBLIC__/plugins/daterangepicker/daterangepicker.js" type="text/javascript"></script>
<div class="wrapper">
    <include file="Public/breadcrumb"/>
    <section class="content ">
        <!-- Main content -->
        <div class="container-fluid">
            <div class="pull-right">
                <a href="javascript:history.go(-1)" data-toggle="tooltip" title="" class="btn btn-default" data-original-title="返回"><i class="fa fa-reply"></i></a>
            </div>
            <div class="panel panel-default">
                <!--<div class="panel-heading">
                    <h3 class="panel-title"><i class="fa fa-list"></i> 添加优惠券</h3>
                </div>-->
                <div class="panel-body ">   
                    <!--表单数据-->
                    <form action="" method="post">              
                        <!--通用信息-->
                    <div class="tab-content col-md-10">                 	  
                        <div class="tab-pane active" id="tab_tongyong">                           
                            <table class="table table-bordered">
                                <tbody>
                                <tr>
                                    <td class="col-sm-2">优惠券名称：</td>
                                    <td class="col-sm-4">
                                        <input type="text" value="{$coupon.name}" class="form-control" id="name" name="name" >
                                        <span id="err_attr_name" style="color:#F00; display:none;"></span>                                        
                                    </td>
                                    <td class="col-sm-4">请填写优惠券名称
                                    </td>
                                </tr>  
<!--                                <tr>-->
<!--                                    <td class="col-sm-2">选择店铺：</td>-->
<!--                                    <td class="col-sm-4">-->
<!--                                        <select name="store_id" id="store_id" class="form-control">-->
<!--                                            <option <if condition="$coupon['store_id'] eq $v['store_id']">checked</if> value="0">平台优惠券</option>-->
<!--                                            <foreach name="store" item="v" key="k" >-->
<!--                                                <option <if condition="$coupon['store_id'] eq $v['store_id']">checked</if> value="{$v.store_id}">{$v.store_name}</option>-->
<!--                                            </foreach>-->
<!--                                        </select>-->
<!--                                    </td>-->
<!--                                </tr>-->
                                <tr>
                                    <td>优惠券面额：</td>
                                    <td >
                         				<input type="text" value="{$coupon.money}" class="form-control" id="money" name="money"  onpaste="this.value=this.value.replace(/[^\d.]/g,'')" onkeyup="this.value=this.value.replace(/[^\d.]/g,'')"/>
                                    </td>
                                    <td class="col-sm-4">优惠券可抵扣金额</td>
                                </tr>  
                                <tr>
                                    <td>消费金额：</td>
                                    <td>
                      					<input type="text" value="{$coupon.condition}" class="form-control active" id="condition" name="condition"  onpaste="this.value=this.value.replace(/[^\d.]/g,'')" onkeyup="this.value=this.value.replace(/[^\d.]/g,'')" />
                                    </td>
                                    <td class="col-sm-4">订单需满足的最低消费金额(必需为整数)才能使用</td>
                                </tr>
                                <tr>
			                        <td>优惠券类型:</td>
			                        <td id="order-status">
			                         	<!--<input name="type" type="radio" value="0" <if condition="$coupon['type'] eq 0">checked</if> >面额模板-->
			                            <input name="type" type="radio" value="1" checked >按用户发放			                           
			                            <!--<input name="type" type="radio" value="2" <if condition="$coupon['type'] eq 2">checked</if> >注册发放-->
			                            <!--<input name="type" type="radio" value="3" <if condition="$coupon['type'] eq 3">checked</if> >邀请发放-->
			                            <!--<input name="type" type="radio" value="4" <if condition="$coupon['type'] eq 4">checked</if> >线下发放-->
			                        </td>
			                    </tr> 
			                    <tr>
			                    	<td>发放数量:</td>
			                    	<td><input type="text" value="{$coupon.createnum}" class="form-control" id="createnum" name="createnum" placeholder="0" onpaste="this.value=this.value.replace(/[^\d]/g,'')" onkeyup="this.value=this.value.replace(/[^\d]/g,'')" /></td>
			                    	<td class="col-sm-4">发放数量限制(默认为0则无限制)</td>
			                    </tr>
			                    <tr class="timed">
			                        <td>发放起始日期:</td>
			                        <td>
			                            <div class="input-prepend input-group">
			                                <span class="add-on input-group-addon">
			                                      <i class="glyphicon glyphicon-calendar fa fa-calendar">  </i>
			                                </span>
			                                <input type="text" value="{$coupon.send_start_time|date='Y-m-d H:i:s',###}" class="form-control" id="send_start_time" name="send_start_time">
			                            </div>
			                        </td>
			                        <td class="col-sm-4"></td>
			                    </tr>
			
			                    <tr class="timed">
			                        <td>发放结束日期:</td>
			                        <td>
			                            <div class="input-prepend input-group">
			                                <span class="add-on input-group-addon">
			                                        <i class="glyphicon glyphicon-calendar fa fa-calendar"> </i>
			                                </span>
			                                <input type="text" value="{$coupon.send_end_time|date='Y-m-d H:i:s',###}" class="form-control" id="send_end_time" name="send_end_time">
			                            </div>
			                        </td>
			                        <td class="col-sm-4"></td>
			                    </tr>
					            <tr>
			                        <td>使用起始日期:</td>
			                        <td>
			                            <div class="input-prepend input-group">
			                                <span class="add-on input-group-addon">
			                                    <i class="glyphicon glyphicon-calendar fa fa-calendar"></i>
			                                </span>
			                                <input type="text" value="{$coupon.use_start_time|date='Y-m-d H:i:s',###}" class="form-control" id="use_start_time" name="use_start_time">
			                            </div>
			                        </td>
			                        <td class="col-sm-4"></td>
			                    </tr> 
			                    <tr>
			                        <td>使用结束日期:</td>
			                        <td>
			                            <div class="input-prepend input-group">
			                                <span class="add-on input-group-addon">
			                                    <i class="glyphicon glyphicon-calendar fa fa-calendar"></i>
			                                </span>
			                                <input type="text" value="{$coupon.use_end_time|date='Y-m-d H:i:s',###}" class="form-control" id="use_end_time" name="use_end_time">
			                            </div>
			                        </td>
			                        <td class="col-sm-4"></td>
			                    </tr>  
			                    <tr>
									<td>
									    <div class="">                                        
                                            <a class="btn btn-primary" href="javascript:void(0);" onclick="selectGoods()" ><i class="fa fa-search"></i> 添加商品</a>
                                        </div> 
                                    </td>
									
									<td>
                                 
									
									</td>
								</tr>
								
								
				
                           
                                </tbody> 
                                <tbody id="goods_list">
                                <volist name="coupon.goodsList" id="list">
                                   <tr>
                                   	<td class="text-left">
                                            <input type="hidden" name="goods_id[]" value="{$list.goods_id}"/>{$list.goods_id}
                                       </td>
                                       <td class="text-left"> {$list.goods_name}</td>
    								   <td class="text-left">{$list.cat_name}</td>
                                       <td><a href="javascript:void(0)" onclick="javascript:$(this).parent().parent().remove();">删除</a></td>
                                   </tr>                              
    			            	</volist>
								 
								</tbody>
                                <tfoot>
                                	<tr>
                                	<td>
                                		<input type="hidden" name="id" value="{$coupon.id}">
                                	</td>
                                	<td class="col-sm-4"></td>
                                	<td class="text-right"><input class="btn btn-primary" type="submit" value="保存"></td>
                                	</tr>
                                </tfoot>                               
                            </table>
                        </div>                           
                    </div>              
			    	</form><!--表单数据-->
                </div>
            </div>
        </div>
    </section>
</div>

<script>
// $('input[type="radio"]').click(function(){
//     if($(this).val() == 1){
//     	$('.timed').hide();
//     }else{
//     	$('.timed').show();
//     }
// })

function toggleCheckboxes() {
        var checkboxes = document.getElementsByClassName("fenbu_id");
        var selectAllCheckbox = document.getElementById("selectAll");
        for (var i = 0; i < checkboxes.length; i++) {
            checkboxes[i].checked = selectAllCheckbox.checked;
        }
    }
$(function(){
    data_pick('send_start_time');
    data_pick('send_end_time');
    data_pick('use_start_time');
    data_pick('use_end_time');
    $('input[type="radio"]:checked').trigger('click');
})
  function selectGoods(){
// 	var goods_id = []; 
// 	//过滤选择重复商品
// 	$('input[name*="goods_id"]').each(function(i,o){
// 		goods_id.push($(o).val());
// 	});

    var url = '/index.php?m=Seller&c=Coupon&a=search_brand';
    layer.open({
        type: 2,
        title: '选择商品',
        shadeClose: true,
        shade: 0.3,
        area: ['70%', '80%'],
        content: url, 
    });
}  
function data_pick(id){
    var myDate = new Date();
    $('#'+id).daterangepicker({
    	format:"YYYY-MM-DD HH:mm:ss",
        singleDatePicker: true,
        showDropdowns: true,
        minDate:myDate.getFullYear()+'-'+myDate.getMonth()+'-'+myDate.getDate(),
        maxDate:'2030-01-01',
		timePicker : true, //是否显示小时和分钟  
        timePickerIncrement:1,//time选择递增数
		timePicker12Hour : false, //是否使用12小时制来显示时间 		
        locale : {
            applyLabel : '确定',
            cancelLabel : '取消',
            fromLabel : '起始时间',
            toLabel : '结束时间',
            customRangeLabel : '自定义',
            daysOfWeek : [ '日', '一', '二', '三', '四', '五', '六' ],
            monthNames : [ '一月', '二月', '三月', '四月', '五月', '六月','七月', '八月', '九月', '十月', '十一月', '十二月' ],
            firstDay : 1
        }
    });
}
function call_backs(table_html)
{
	layer.closeAll('iframe');
	$('#goods_list').append(table_html);
}
</script>
</body>
</html>